#!/bin/bash -e

# install ssh-agent
which ssh-agent || ( apt-get update -y && apt-get install openssh-client rsync -y )

# run ssh-agent
eval $(ssh-agent -s)

# add ssh key stored in SSH_CI_KEY variable to the agent store
echo "$SSH_CI_KEY" | tr -d '\r' | ssh-add -

# disable host key checking (NOTE: makes you susceptible to man-in-the-middle attacks)
mkdir -p ~/.ssh
echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
